<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="robots" content="noindex, follow"/>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico"/>
    <link rel="stylesheet" href="css/vendor.min.css">
    <link rel="stylesheet" href="css/plugins.min.css">
    <link rel="stylesheet" href="css/style.min.css">
    <style type="text/css">
        .pwde-table {
            width: 100%;
            text-align: center;
            border: solid 1px black;
        }
        .pwde-tr {
            background-color: #006fb7;
        }
        .pwde-table tr, td, th {
            height: 40px;
            border: solid 1px black;
        }
        html{
            height: 100%;
            overflow-y: hidden;
        }
        body{
            height: 100%;
            overflow-y: auto;
        }
    </style>
</head>
<body>
<div class="main-wrapper">
    <div class="container" style="margin-top: 20px;">
        <div>
            <img src="img/shop/etl.jpg">
        </div>
        <div style="margin-top: 20px;">
            <div style="display: flex;justify-content: space-between;align-items: center; height: 50px;">
                <div>
                    展示
                    <select style="border: 1px solid black; height: 30px; width: 50px; border-radius: 4px;" id="limit" onchange="getPageLimit()">
                        <option>2</option>
                        <option>3</option>
                        <option>5</option>
                        <option selected>20</option>
                        <option>30</option>
                    </select>
                    条数据
                </div>
                <div>
                    搜索：<input type="text" id="key" style="border: 1px solid black; height: 30px; width: 210px;  border-radius: 4px;">
                </div>
            </div>
            <table class="pwde-table">
                <thead>
                    <tr class="pwde-tr" style="color: white;">
                        <th width="25%">序号</th>
                        <th width="25%">号码</th>
                        <th>价格（K）</th>
                        <th width="25%">状态</th>
                    </tr>
                </thead>
                <tbody id="test">

                </tbody>
            </table>
            <div style="display: flex;justify-content: space-between;align-items: center; height: 50px;">
                <div></div>
                <div>
                    <button style="padding: 0px 10px; size: 30px" onclick="toPage(1)"><</button>
                    <input type="text" style="border: 1px solid black;height: 30px;width: 40px;border-radius: 4px;text-align: center;" value="1" id="page">
                    <button style="padding: 0px 10px; size: 30px" onclick="toPage(2)">></button>
                </div>
            </div>
        </div>
    </div>
<!--    <div class="footer-area">-->
<!--        <div class="footer-bottom py-3" data-bg-color="#1EB9EE">-->
<!--            <div class="container">-->
<!--                <div class="row">-->
<!--                    <div class="col-lg-12">-->
<!--                        <div class="copyright">-->
<!--                            <span class="copyright-text text-white">Copyright &copy; 2023.LAO Asia Unicom All rights reserved.</span>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
<!--    </div>-->
<!--    <a class="scroll-to-top" href="">-->
<!--        <i class="fa fa-chevron-up"></i>-->
<!--    </a>-->
</div>
<div class="product-tab-area section-space-top-55" style="padding-bottom: 50px;">
    <div class="container">
        <div class="row">
            <div class="col-lg-12">
                <ul class="nav product-tab-nav product-tab-style-2" role="tablist">
                    <li class="nav-item" role="presentation">
                        <a class="active btn aaa" id="description-tab" data-bs-toggle="tab" href="#description" role="tab" aria-controls="description" aria-selected="true" i18n="">
                            选号规则及注意事项
                        </a>
                    </li>
                </ul>
                <div class="tab-content product-tab-content">
                    <div class="tab-pane fade show active" id="description" role="tabpanel" aria-labelledby="description-tab">
                        <div class="product-description-body">
                            <p class="short-desc mb-0" id="rules"></p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="js/jquery/jquery.min.js"></script>
<script src="layui/layui.js"></script>
<script src="js/token.js"></script>
<script src="js/config.js"></script>
<script src="js/jquery.i18n.min.js"></script>
<script src="js/multi_lang_config.js"></script>
<script>

    var layer = layui.layer;
    var form = layui.form;

    var moduleName = "shop";
    var defaultLang = layui.data('langTab').langType;
    initLangConfig({
        defaultLang:defaultLang,
        filePath: "js/i18n/"+moduleName+"/",
        module:moduleName,
        base:"js/"
    })
    var i18np = null;
    function changeLang(lang) {
        defaultLang = lang;
        reloadI18n({
            defaultLang:lang,
            filePath: "js/i18n/"+moduleName+"/",
            module:moduleName,
        })
        i18np.loadProperties(moduleName);

        simRulesInit();
    }

    layui.config({base: 'js/'})
        // 继承treetable.js插件
        .extend({i18np: 'i18n'}).use([ 'i18np','jquery'], function () {
        i18np = layui.i18np;
        i18np.loadProperties(moduleName);
    });

    $(function () {
        getTableData();
        getSimRules();
    })

    var simRules = {};
    function getSimRules() {
        $.ajax({
            url: HOST+"phoneOrSales/getPhoneOrSalesByType?type=6",
            type: "GET",
            success: function (res) {
                simRules = res.data;
                simRulesInit();
            }
        })
    }

    function simRulesInit() {
        if (defaultLang == "zh") {
            $('#rules').html(simRules.contentZh);
        } else if (defaultLang == "la") {
            $('#rules').html(simRules.contentLao);
        } else if (defaultLang == "en") {
            $('#rules').html(simRules.contentEn);
        }
    }

    //总页数
    var totalPage = 1;
    //上一页、下一页
    function toPage(param) {
        var page = $("#page").val();
        if (param == 1){
            if (page > 1){
                page--;
            }else{
                page = 1;
            }
        }else if (param == 2){
            if (page >= totalPage){
                page = totalPage;
            }else{
                page++;
            }
        }
        $("#page").val(page);
        getTableData();
    }
    
    function getPageLimit() {
        $("#page").val(1);
        getTableData();
    }

    function getTableData() {
        let page = $("#page").val();
        let limit = $('#limit').val();
        $.ajax({
            url: HOST + "webapi/sim/getSimByPage",
            type: "GET",
            data:{
                page:page,
                limit:limit,
                key:$("#key").val()
            },
            success: function (res) {
                var trRow = res.data;
                var count = res.count;
                totalPage = count < limit ? 1 : (count%limit==0 ? (count/limit).toFixed(0) : (count/limit + 1).toFixed(0));
                var str1 = "";
                for (var i = 0; i < trRow.length; i++) {
                    let lie=i+1;
                    let status = "";
                    if (trRow[i].status == 1){
                        status = "已卖出";
                    }else if (trRow[i].status == 2){
                        status = "已作废";
                    }else {
                        status = "准备卖出";
                    }
                    str1 += "<tr>\n" +
                        "                        <td>"+lie+"</td>\n" +
                        "                        <td>"+trRow[i].number+"</td>\n" +
                        "                        <td>"+trRow[i].price+"</td>\n" +
                        "                        <td>"+status+"</td>\n" +
                        "                    </tr>";
                }
                $("#test").html(str1);
            }
        })
    }

    //监听回车事件
    $(window).keypress(function (event) {
        if(event.which === 13){
            getTableData();
        }
    })
</script>
</body>
</html>